﻿<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <#include "../common/header.ftl"/>
    <script>
        $(function () {

            $('.btn-input').click(function () {
                var json = $(this).data('json');
                //填充之前先清空 转成DOM
                $("#editForm")[0].reset();
                if (json) /*有数据才显示*/
                {
                    $('input[name="id"]').val(json.id);
                    $('input[name="title"]').val(json.title);
                    $('input[name="sequence"]').val(json.sequence);
                }
                $('input[name="parentTitle"]').val("${(dic.title)!}");
                $('input[name="parentId"]').val("${(dic.id)!}");


                $('#editModal').modal('show');
            });
            $('.btn-submit').click(function () {
                //改用ajax提交
                $('#editForm').ajaxSubmit(function (data) {
                    handleResult(data);
                });
            });

        })


    </script>
</head>
<body>

<!-- Modal -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel">字典目录明细编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/systemdictionaryItem/saveOrUpdate.do" method="post"
                      id="editForm">
                    <input type="hidden" name="id" >

                    <div class="form-group">
                        <label class="col-sm-3 control-label">字典目录：</label>
                        <div class="col-sm-6">
                            <input type="hidden" name="parentId">
                            <input type="text" name="parentTitle" class="form-control" disabled>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">明细标题：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="title"
                                   placeholder="请输入字典明细标题">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">明细序号：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="sequence"
                                   placeholder="请输入字典明细序号">
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary btn-submit">提交</button>
            </div>
        </div>
    </div>
</div>


<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
        <#--设置当前要回显当前菜单,必须在载人菜单前完成设置-->
           <#-- <#assign menu="systemdictionaryItem"/>-->
                <#assign menu="systemDictionaryItem">
            <#include "../common/menu.ftl">
        </div>



        <div class="col-sm-9">

            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">数据字典明细管理</h1>
                </div>
            </div>

            <div class="col-sm-3">

                <ul id="menu" class="list-group">
                    <li class="list-group-item">
                        <a role="button" data-toggle="collapse" data-target="#systemdictionaryitem_detail">
                            <span>字典目录</span>
                        </a>
                        <ul class="in" id="systemdictionaryitem_detail">
                        <#list result as d>
                            <#--高亮显示-->
                            <li class=" ${((qo.parentId??) && d.id==dic.id)?string('active','')}   list-group-item  ">
                                <a  href="/systemdictionaryItem/list.do?parentId=${d.id}">
                                    ${d.title}
                                </a>
                            </li>
                        </#list>
                        </ul>
                    </li>
                </ul>

            </div>
            <div class="col-sm-9">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="" method="post">
                    <input type="hidden" id="currentPage" name="currentPage" value="1">
                    <a href="javascript:;" class="btn btn-success btn-input">
                        <span class="glyphicon glyphicon-plus"></span> 添加
                    </a>
                </form>
                <table class="table table-striped table-hover">
                    <tr>
                        <th>编号</th>
                        <th>标题</th>
                        <th>序号</th>
                        <th>操作</th>
                    </tr>
                    <#--如果pageInfo有数据再进行遍历-->
                    <#if pageInfo??>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td>${entity.title}</td>
                        <td>${entity.sequence}</td>
                        <td>
                            <a class="btn btn-info btn-xs btn-input" href="javascript:;" data-json='${(entity.json)!}'>
                                <span class="glyphicon glyphicon-pencil "></span> 编辑
                            </a>
                           <@shiro.hasPermission name="systemdictionaryItem:delete">
                           <a href="javascript:;" class="btn btn-danger btn-xs btn-delete"
                              data-url="/systemdictionaryItem/delete.do?id=${entity.id}">
                               <span class="glyphicon glyphicon-trash"></span> 删除
                           </a>
                           </@shiro.hasPermission>
                        </td>
                    </tr>
                </#list>

                </table>
                    <#include "../common/page.ftl"/>
                    </#if>
            </div>

        </div>

    </div>
</div>


</body>
</html>